package com.huawei.updatesdk.service.d.a;

import android.text.TextUtils;
import com.huawei.updatesdk.a.b.d.a.c;
import com.huawei.updatesdk.a.b.d.b;
import com.huawei.updatesdk.service.a.e;

public class d extends b {
    private int b = 0;

    static class a {
        public static boolean a(c cVar) {
            com.huawei.updatesdk.a.b.d.a.d a = new d(com.huawei.updatesdk.service.a.c.f(), null).b();
            if (!(a instanceof com.huawei.updatesdk.service.a.d) || a.b() != 0) {
                return false;
            }
            ((com.huawei.updatesdk.service.a.d) a).f();
            if (cVar != null && (cVar instanceof e)) {
                e eVar = (e) cVar;
                if (eVar.g()) {
                    com.huawei.updatesdk.a.a.b.a.a.a.c("StoreTaskEx", "set sign and hcrid again");
                    eVar.q(((com.huawei.updatesdk.service.a.d) a).e());
                }
            }
            return true;
        }

        public static boolean a(c cVar, com.huawei.updatesdk.a.b.d.a.d dVar) {
            return (cVar instanceof e) && !(dVar.b() == 0 && dVar.a() == 0);
        }

        private static boolean b(int i) {
            return i == 1022 || i == 1021 || i == 1012 || i == 1011;
        }
    }

    public d(c cVar, com.huawei.updatesdk.a.b.d.a.a aVar) {
        super(cVar, aVar);
    }

    public void a(com.huawei.updatesdk.a.b.d.a.d dVar) {
        if (!(this.a instanceof com.huawei.updatesdk.service.a.c)) {
            if (a.b(dVar.b()) || a.a(this.a, dVar)) {
                int i = this.b;
                this.b = i + 1;
                if (i < 3) {
                    com.huawei.updatesdk.a.a.b.a.a.a.d("StoreTaskEx", "reCallFrontSync, hcrID or sign error! method:" + this.a.a() + ", rtnCode:" + dVar.b());
                    if (a.a(this.a)) {
                        dVar.a(1);
                    }
                }
            }
        }
    }

    public String c() {
        Object a = a.a();
        return TextUtils.isEmpty(a) ? super.c() : a;
    }
}
